#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int a[10][10] = {0};
	int cnt = 1;
	int top = 0, bottom = n - 1, left = 0, right = n - 1;

	while (cnt <= n * n) {

		for (int j = left; j <= right; j++) {
			a[top][j] = cnt++;
		}
		top++;

		for (int i = top; i <= bottom; i++) {
			a[i][right] = cnt++;
		}
		right--;

		if (top <= bottom) {
			for (int j = right; j >= left; j--) {
				a[bottom][j] = cnt++;
			}
			bottom--;
		}

		if (left <= right) {
			for (int i = bottom; i >= top; i--) {
				a[i][left] = cnt++;
			}
			left++;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			printf("%3d", a[i][j]);
		}
		printf("\n");
	}

	return 0;
}
